<!-- 业务功能管理 -->
<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-tickets"></i> 功能模块列表</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-button class="handSearchBut" type="primary" icon="search" @click="search">搜索</el-button>
                <el-input v-model="select_word" placeholder="筛选关键词" class="handle-input mr10"></el-input>
            </div><br/>
            <el-table :data="data" border style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
                <el-table-column prop="id" label="企业编号" sortable width="150"></el-table-column>
                <el-table-column prop="name" label="企业名称" width="250"></el-table-column>
                <el-table-column prop="modDes" label="企业基本信息" :formatter="formatter"></el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination @current-change="handleCurrentChange" layout="prev, pager, next" :total="1000">
                </el-pagination>
            </div>
        </div>

    </div>
</template>

<script>
    export default {
        name: 'basetable',
        data() {
            return {
                url: './static/vuetable.json',
                tableData: [
                    {
                        "id": "编号1",
                        "name": "企业名称1",
                        "modDes": "企业基本信息，企业基本信息，企业基本信息，企业基本信息......",
                    },
                    {
                        "id": "编号2",
                        "name": "企业名称2",
                        "modDes": "企业基本信息，企业基本信息，企业基本信息，企业基本信息，......",
                    }
                ],
                cur_page: 1,
                multipleSelection: [],
                select_cate: '',
                select_word: '',
                del_list: [],
                is_search: false,
                editVisible: false,
                delVisible: false,
                form: {
                    name: '',
                    id: '',
                    modDes: ''
                },
                dialogTitle: '添加',
                idx: -1
            }
        },
        created() {
            this.getData();
        },
        computed: {
            data() {
                return this.tableData.filter((d) => {
                    let is_del = false;
                    for (let i = 0; i < this.del_list.length; i++) {
                        if (d.name === this.del_list[i].name) {
                            is_del = true;
                            break;
                        }
                    }
                    if (!is_del) {
                        if (d.modDes.indexOf(this.select_cate) > -1 &&
                            (d.name.indexOf(this.select_word) > -1 ||
                                d.modDes.indexOf(this.select_word) > -1)
                        ) {
                            return d;
                        }
                    }
                })
            }
        },
        methods: {
            // 分页导航
            handleCurrentChange(val) {
                this.cur_page = val;
                this.getData();
            },
            // 获取 easy-mock 的模拟数据
            getData() {
                // this.$axios.post(this.url, {
                //     page: this.cur_page
                // }).then((res) => {
                //     this.tableData = res.data.list;
                // })
                console.log('获取数据')
            },
            search() {
                this.is_search = true;
            },
            formatter(row, column) {
                return row.modDes;
            },
            filterTag(value, row) {
                return row.tag === value;
            }
        }
    }

</script>

<style scoped>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 120px;
    }

    .handle-input {
        width: 300px;
        display: inline-block;
        float: right;
    }
    .handSearchBut {
       float: right;
    }
    .del-dialog-cnt{
        font-size: 16px;
        text-align: center
    }
</style>
